<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        /*
            ()  整体
            |   或, 会对左右的整体生效，而不是单个字符，除非你用()限制一下
            []   代表1个
        */ 

        // ()
        let reg1 = /^(12){2}$/;//12需要作为整体出现两次，且边界符限定前后不能有内容
        console.log(reg1.test('1212'));//true
        console.log(reg1.test('121212'));//true
        console.log(reg1.test('212122'));//true

        console.log('----------------------------------------');

        // |
        let reg2 = /abc|def/;//包含adc或者包含def, 不是包含abcef或者abdef
        console.log(reg2.test('abc'));//true
        console.log(reg2.test('def'));//true

        console.log('----------------------------------------');

        // []
        let reg3 = /[abcdef]/;//包含abcdef里的任意一个
        console.log(reg3.test('zzz'));//false
        console.log(reg3.test('a'));//true
    </script>
</body>
</html>